package com.rjkj.medicalwaste.network.retrofit

import com.alibaba.fastjson.JSONObject
import com.rjkj.medicalwaste.bean.*
import com.rjkj.medicalwaste.network.response.BaseResponse
import okhttp3.ResponseBody
import retrofit2.Call
import retrofit2.Response
import retrofit2.http.*

interface ApiInterface {
    //错误日志上传
    @POST("errorInfo/sendErrorLog")
    suspend fun sendStack(
        @Body jsonObject: JSONObject?
    ): BaseResponse<String?>

    //获取绑定的所有医院数据
    @GET("/user/getAllUser")
    suspend fun getAllUser(
        @Header("CHANGE_URL") url: String = "",
        @Query("deviceSN") deviceSN: String
    ): BaseResponse<GetAllUserRsp?>


    //绑定唯一号
    @GET("/device/bindEquipmentId")
    suspend fun bingEquipmentId(
        @Header("CHANGE_URL") url: String = "",
        @Query("deviceSN") deviceSN: String,
        @Query("id") id: String,
        @Query("cardNo") cardNo: String
    ): BaseResponse<BindEquipmentIdRsp?>

    //上传医废数据
    @POST("/pack/collectPackWithMedicalWaste")
    suspend fun uploadData(
        @Header("CHANGE_URL") url: String = "",
        @Body garbageBeanList: List<GarbageBean>
    ): BaseResponse<String>

    //查询医院列表
    @GET("/device/findHospital")
    suspend fun findHospital(
        @Header("CHANGE_URL") url: String = "",
        @Query("message") message: String
    ): BaseResponse<List<HospitalBean>>

    //绑定医院
    @GET("/device/bindHospitalId")
    suspend fun bindHospitalId(
        @Header("CHANGE_URL") url: String = "",
        @Query("hospitalId") hospitalId: String,
        @Query("deviceSN") deviceSN: String,
        @Query("cardNo") cardNo: String
    ): BaseResponse<GetAllUserRsp?>

    //各种医废数量
    @GET("/medicalWaste/getMedicalNumber")
    suspend fun getMedicalNumber(
        @Header("CHANGE_URL") url: String = "",
        @Query("hospitalId") hospitalId: String,
        @Query("deviceSn") deviceSN: String,
    ): BaseResponse<GetMedicalNumber?>

    //pack回收
    @POST("/pack/collectPackWithMedicalWaste")
    suspend fun collectPackWithMedicalWaste(@Body garbageBeanList: List<GarbageBean>): BaseResponse<String>

    //根据科室下拉pack
    @POST("/pack/findPackByDepartment")
    suspend fun findPackByDepartment(
        @Header("CHANGE_URL") url: String = "",
        @Body departmentList: List<String>
    ): BaseResponse<List<PackBean>>

    //入库未装箱医废下拉
    @GET("/medicalWaste/getReviewNotBoxGarbage")
    suspend fun getReviewNotBoxGarbage(
        @Header("CHANGE_URL") url: String = "",
        @Query("deviceSN") deviceSN: String
    ): BaseResponse<List<GarbageBean>>


    //pack回收
    @POST("/medicalWaste/handover")
    suspend fun handover(
        @Header("CHANGE_URL") url: String = "",
        @Body req: HandoverReq,
    ): BaseResponse<String>

    //出库报表
    @GET("/medicalWaste/getWaitHandoverGarbage")
    suspend fun getWaitHandoverGarbage(
        @Header("CHANGE_URL") url: String = "",
        @Query("deviceSN") deviceSN: String,
        @Query("handoverQRCode") handoverQRCode: String
    ): BaseResponse<List<WaitHandoverGarbageBean>>

    //出库报表
    @GET("/medicalWaste/handoverReport")
    suspend fun handoverReport(
        @Header("CHANGE_URL") url: String = "",
        @Query("deviceSN") deviceSN: String
    ): BaseResponse<List<HandoverInfoBean>>

    @GET("/sqlInfo/getSqlInfo")
    suspend fun getSqlInfo(
        @Header("CHANGE_URL") url: String = "",
        @Query("deviceSN") deviceSN: String
    ): BaseResponse<List<SqlInfoBean>>


    @POST("/device/historyInfo")
    suspend fun historyInfo(
        @Header("CHANGE_URL") url: String = "",
        @Body jsonObject: JSONObject?
    ): BaseResponse<String>

    @GET("/sqlInfo/execSqlResult")
    suspend fun execSqlResult(
        @Header("CHANGE_URL") url: String = "",
        @Query("no") no: String,
        @Query("result") result: Int
    ): BaseResponse<List<SqlInfoBean>>

    //科室打卡
    @POST("/cleanRoute/departmentClock")
    suspend fun departmentClock(
        @Header("CHANGE_URL") url: String = "",
        @Body req: Array<DepartmentClockReq>,
    ): BaseResponse<String>

    //根据清理工查询入库未装箱医废
    @GET("/medicalWaste/getReviewNotBoxGarbageByCleaner")
    suspend fun getReviewNotBoxGarbageByCleaner(
        @Header("CHANGE_URL") url: String = "",
        @Query("deviceSN") deviceSN: String,
        @Query("cleanerQRCode") cleanerQRCode: String,
        @Query("hospitalId") hospitalId: String,
        @Query("reviewStorageQRCode") reviewStorageQRCode: String
    ): BaseResponse<List<GarbageBean>>

    //查询远程配置的ip与端口
    //根据清理工查询入库未装箱医废
    @GET("/device/findIPAndPort")
    suspend fun findIPAndPort(
//        @Header("CHANGE_URL")url:String = "https://www.baidu.com/" ,
        @Query("deviceSn") deviceSN: String,
    ): BaseResponse<IPAndPortBean>


    //查询远程配置的ip与端口
    //根据清理工查询入库未装箱医废
    @POST
    suspend fun test(
        @Header("Authorization") auth: String = "APPCODE 2a935868581f450984655cad18e6b728",
        @Url url: String = "https://ocrapi-advanced.taobao.com/ocrservice/advanced",
        @Body req: OCRBean,
    ): BaseResponse<String>


    //根据医院查询待打包的数据
    @GET("/pack/findPackByHospitalId")
    suspend fun findPackByHospitalId(
        @Header("CHANGE_URL") url: String = "",
        @Query("deviceSn") deviceSn: String,
        @Query("hospitalId") hospitalId: String,
    ): BaseResponse<List<PackBean>>
    //根据医院查询待打包的数据
    @GET("/device/updateDevice")
    suspend fun updateDevice(
        @Header("CHANGE_URL") url: String = "",
        @Query("deviceSn") deviceSn: String,
        @Query("version") version: String,
    ): BaseResponse<UploadBean>
    @Streaming
    @GET
    suspend fun downloadFile(@Url url: String): Response<ResponseBody>
}